<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改产品规格')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <div class="form-group">
        <div class="col-sm-6">
            <form class="form-horizontal m" id="form-specification-edit" th:object="${product}">
                <div class="form-group">
                    <label class="col-sm-3 control-label">品名：</label>
                    <div class="col-sm-8">
                        <div th:text="*{productName}"></div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">系列：</label>
<!--                    <div class="col-sm-8" th:with="seriesData=${@productBo.selectSeriesById(*{styleId})}">-->
                    <div th:text="*{seriesName}"></div>
<!--                        <div  th:text="${seriesData.seriesName}"></div>-->
<!--                        <select name="seriesId" th:with="seriesData=${@productBo.selectSeriesList(null)}">-->
<!--                            <option value="">必选</option>-->
<!--                            <option th:each="series : ${seriesData}" th:text="${series.seriesName}"-->
<!--                                    th:selected="${series.seriesId eq product.seriesId}"-->
<!--                                    th:value="${series.seriesId}"></option>-->
<!--                        </select>-->
<!--                    </div>-->
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">风格：</label>
                    <div class="col-sm-8">
                        <div th:text="*{styleName}"></div>
<!--                        <select name="styleId" th:with="styleData=${@productBo.selectProStyleList(null)}">-->
<!--                            <option value="">必选</option>-->
<!--                            <option th:each="style : ${styleData}" th:text="${style.styleName}"-->
<!--                                    th:selected="${style.styleId eq product.styleId}"-->
<!--                                    th:value="${style.styleId}"></option>-->
<!--                        </select>-->
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">规格：</label>
                    <div class="col-sm-8">
                        <div th:text="*{specificationName}"></div>
<!--                        <select name="specificationId"-->
<!--                                th:with="specificationData=${@productBo.selectProSpecificationList(null)}">-->
<!--                            <option value="">必选</option>-->
<!--                            <option th:each="specification : ${specificationData}"-->
<!--                                    th:text="${specification.specificationName}"-->
<!--                                    th:value="${specification.specificationId}"-->
<!--                                    th:selected="${specification.specificationId eq product.specificationId}"></option>-->
<!--                        </select>-->
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">材质：</label>
                    <div class="col-sm-8">
                        <div th:text="*{qualityName}"></div>
<!--                        <select name="qualityId" th:with="qualityData=${@productBo.selectProQualityList(null)}">-->
<!--                            <option value="">必选</option>-->
<!--                            <option th:each="quality : ${qualityData}" th:text="${quality.qualityName}"-->
<!--                                    th:value="${quality.qualityId}"-->
<!--                                    th:selected="${quality.qualityId eq product.qualityId}"></option>-->
<!--                        </select>-->
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label ">产地：</label>
                    <div class="col-sm-8">
                        <div th:text="*{productLocation}"></div>
<!--                        <input class="form-control" type="text" name="productLocation" id="productLocation"-->
<!--                               th:field="*{productLocation}" required>-->
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label ">成本：</label>
                    <div class="col-sm-8">
                        <div th:text="*{productCost}"></div>
<!--                        <input class="form-control" type="text" name="productCost" id="productCost"-->
<!--                               th:field="*{productCost}" required>-->
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label ">数量：</label>
                    <div class="col-sm-8">
                        <div th:text="*{productNumber}"></div>
<!--                        <input class="form-control" type="text" name="productNumber" id="productNumber"-->
<!--                               th:field="*{productNumber}" required>-->
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label ">金额：</label>
                    <div class="col-sm-8">
                        <div th:text="*{productPrice}"></div>
<!--                        <input class="form-control" type="text" name="productPrice" id="productPrice"-->
<!--                               th:field="*{productPrice}" required>-->
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">进口家具在途：</label>
                    <div class="col-sm-8">
                        <div th:text="*{productOnWay}"></div>
<!--                        <select name="productOnWay">-->
<!--                            <option value="0" th:selected="${'0' eq product.productOnWay}">在途</option>-->
<!--                            <option value="1" th:selected="${'1' eq product.productOnWay}">仓库</option>-->
<!--                        </select>-->
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label ">备注：</label>
                    <div class="col-sm-8">
                        <div th:text="*{productRemark}"></div>
<!--                        <input class="form-control" type="text" name="productRemark" id="productRemark"-->
<!--                               th:field="*{productRemark}" required>-->
                    </div>
                </div>
            </form>
        </div>
        <div class="col-sm-6">
            <img th:src="${product.imgUrl}" id="preViewImg">
        </div>
    </div>
</div>

<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width: 700px;height: 700px;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">图库</h4>
            </div>
            <form action="/hcy/product/ProImg/add" id="imgForm" method="post" enctype="multipart/form-data">
                <input type="file" id="inputfile" name="imgFile">
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button>提交更改</button>
                </div>
            </form>
            <button type="button" class="btn btn-primary" onclick="fileSub()">提交更改</button>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<th:block th:include="include :: footer"/>
<script type="text/javascript">
    var prefix = ctx + "hcy/product/product";

    $("#form-specification-edit").validate({
        onkeyup: false,
        rules: {
            productName: {
                remote: {
                    url: ctx + "hcy/product/product/checkProductNameUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "productId": function () {
                            return $("input[name='productId']").val();
                        },
                        "productName": function () {
                            return $.common.trim($("#productName").val());
                        }
                    },
                    dataFilter: function (data, type) {
                        return $.validate.unique(data);
                    }
                }
            },
        },
        messages: {
            "productName": {
                remote: "品名已经存在"
            },
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-specification-edit').serialize());
        }
    }
</script>
</body>
</html>
